//
//  MyFilmCommentListCell.m
//  TravelFollowYourHeart
//
//  Created by ENERGY on 2018/1/22.
//  Copyright © 2018年 Lwx. All rights reserved.
//

#import "MyFilmCommentListCell.h"

@interface MyFilmCommentListCell()
@property (nonatomic, strong)UIImageView * iconImage;
@property (nonatomic, strong)UILabel * nameLab;
@property (nonatomic, strong)UILabel * dataLab;
@property (nonatomic, strong)UILabel * contentLab;
@property (nonatomic, strong)UIView * borderView;
@property (nonatomic, strong)NSString * mid;
@end

@implementation MyFilmCommentListCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.iconImage];
        [self.contentView addSubview:self.nameLab];
        [self.contentView addSubview:self.dataLab];
        [self.contentView addSubview:self.contentLab];
        [self.contentView addSubview:self.borderView];
    }return self;
}

- (UIImageView *)iconImage{
    if (!_iconImage) {
        _iconImage = [[UIImageView alloc] init];
        _iconImage.backgroundColor = [UIColor yellowColor];
    }return _iconImage;
}

- (UILabel *)nameLab{
    if (!_nameLab) {
        _nameLab = [[UILabel alloc] init];
        _nameLab.font = DEF_FontSize_14;
        _nameLab.text = @"名字框";
    }return _nameLab;
}

- (UILabel *)dataLab{
    if (!_dataLab) {
        _dataLab = [[UILabel alloc] init];
        _dataLab.font = DEF_FontSize_12;
        _dataLab.text = @"2018年00月00日  00：00：00";
    }return _dataLab;
}

- (UILabel *)contentLab{
    if (!_contentLab) {
        _contentLab = [[UILabel alloc] init];
        _contentLab.font = DEF_FontSize_14;
        _contentLab.text = @"哈哈哈哈哈哈";
    }return _contentLab;
}

- (UIView *)borderView{
    if (!_borderView) {
        _borderView = [[UIView alloc] init];
        _borderView.backgroundColor = getColor(bgColor);
    }return _borderView;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    int iconImageW = 30;
    int border = 10;
    int labH = iconImageW / 2;
    self.iconImage.frame = CGRectMake(border, border, iconImageW, iconImageW);
    self.nameLab.frame = CGRectMake(self.iconImage.right + border / 2, self.iconImage.top, SCREEN_WIDTH - self.iconImage.right - border, labH);
    self.dataLab.frame = CGRectMake(self.nameLab.left, self.nameLab.bottom, self.nameLab.width, labH);
    if ([self.delegate respondsToSelector:@selector(getLabelHeightWithText:width:font:)]) {
        self.contentLab.frame = CGRectMake(border, self.iconImage.bottom + border, SCREEN_WIDTH - 2*border, [self.delegate getLabelHeightWithText:self.contentLab.text width:SCREEN_WIDTH - 2*border font:14]);
    }
//    if ([self.delegate respondsToSelector:@selector(getLabelHeightWithText:width:font:)]) {
//        CGFloat contentLabH = [self.delegate getLabelHeightWithText:self.contentLab.text width:SCREEN_WIDTH - 2*border font:14];
//        self.contentLab.frame = CGRectMake(self.iconImage.left, self.iconImage.bottom + border, SCREEN_WIDTH - 2*border, contentLabH);
//    }
    self.borderView.frame = CGRectMake(0, self.contentView.bottom, SCREEN_WIDTH, 1);
}

- (void)setModelData:(MyFilmCommentModelData *)modelData{
    _modelData = modelData;
    [self.iconImage sd_setImageWithURL:[NSURL URLWithString:modelData.avatar]];
    self.nameLab.text = modelData.nickname;
    self.dataLab.text = modelData.addtime;
    self.contentLab.text = modelData.content;
    self.mid = modelData.mid;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
